<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>模糊搜索案例</title>
    <script src="./vue.js"></script>
</head>

<body>
    <div id="box">
        <input type="text" v-model="inputValue">
        <ul>
            <li v-for="(item, index) in dataList" :key="index">{{item}}</li>
        </ul>
    </div>

    <script>
        const obj = {
            data() {
                return {
                    inputValue: "",
                    dataList: ["aaa", "bbb", "ccc", "abc", "abb", "aab", "bcd", "add", "bbd"],
                    backList: ["aaa", "bbb", "ccc", "abc", "abb", "aab", "bcd", "add", "bbd"]
                }
            },
            watch: {
                inputValue() {
                    this.dataList = this.backList.filter(item => item.includes(this.inputValue))
                }
            }
        }
        Vue.createApp(obj).mount("#box")
    </script>
</body>

</html>